/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nutmotion.controller;

import com.nutmotion.model.bean.ListsBean;
import com.nutmotion.model.bean.UserBean;
import com.nutmotion.model.jpa.Stock;
import com.nutmotion.model.jpa.Trade;
import com.nutmotion.service.TradeService;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author Manu
 */
@ManagedBean
@RequestScoped
public class TestFindingByStockController {
    @ManagedProperty(value="#{userBean}")
    private UserBean userBean;
    
    @ManagedProperty(value="#{listsBean}")
    private ListsBean listsBean;
        
    private Trade beanTrade;    
    
    private List<Trade> tradeResults;    
    
    @PostConstruct
    private void init() {
        this.beanTrade = Trade.build();                
        this.beanTrade.setUser(userBean.getUser());
    }
    
    public void findTrades() {
        //tmp            
        setTradeResults(new TradeService().match(this.beanTrade));
    }
    
//    public void findById() {        
//        int stockId=this.getBeanStock().getId();
//        Stock stockResult=mainService.findById(stockId);        
//        if (stockResult==null) {
//            stockResult=new Stock();
//            stockResult.setId(stockId);
//        }
//          
//        this.setBeanStock(stockResult);    
//    }

    /**
     * @return the beanTrade
     */
    public Trade getBeanTrade() {
        return beanTrade;
    }

    /**
     * @param beanTrade the beanTrade to set
     */
    public void setBeanTrade(Trade beanTrade) {
        this.beanTrade = beanTrade;
    }

    /**
     * @return the tradeResults
     */
    public List<Trade> getTradeResults() {
        return tradeResults;
    }

    /**
     * @param tradeResults the tradeResults to set
     */
    public void setTradeResults(List<Trade> tradeResults) {
        this.tradeResults = tradeResults;        
    }

    /**
     * @return the userBean
     */
    public UserBean getUserBean() {
        return userBean;
    }

    /**
     * @param userBean the userBean to set
     */
    public void setUserBean(UserBean userBean) {
        this.userBean = userBean;
    }

    /**
     * @return the listsBean
     */
    public ListsBean getListsBean() {
        return listsBean;
    }

    /**
     * @param listsBean the listsBean to set
     */
    public void setListsBean(ListsBean listsBean) {
        this.listsBean = listsBean;
    }

}
